/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Main;


import java.awt.Color;
import java.awt.HeadlessException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

/**
 *
 * @author anas
 */
public class Client extends javax.swing.JInternalFrame {

    
    Connection conn= null;
    ResultSet rs = null;
    PreparedStatement ps =null;
    
    public Client() {
        initComponents();
        conn=gestion_chambes_hotel.Gestion_Chambes_Hotel.DB_Connection();
    }

    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel13 = new javax.swing.JLabel();
        buttonGroup1 = new javax.swing.ButtonGroup();
        buttonGroup2 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        C2 = new javax.swing.JLabel();
        N2 = new javax.swing.JLabel();
        P2 = new javax.swing.JLabel();
        T2 = new javax.swing.JLabel();
        CIN_Client = new javax.swing.JTextField();
        Nom_Client = new javax.swing.JTextField();
        Prenom_Client = new javax.swing.JTextField();
        Numero_Tele_Client = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        C1 = new javax.swing.JLabel();
        N1 = new javax.swing.JLabel();
        P1 = new javax.swing.JLabel();
        T1 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        E2 = new javax.swing.JLabel();
        M2 = new javax.swing.JLabel();
        ME2 = new javax.swing.JLabel();
        D2 = new javax.swing.JLabel();
        EN2 = new javax.swing.JLabel();
        Date_Naissance_Client = new com.toedter.calendar.JDateChooser();
        Email_Client = new javax.swing.JTextField();
        oui = new javax.swing.JRadioButton();
        non = new javax.swing.JRadioButton();
        Metier_Client = new javax.swing.JTextField();
        Nombre_Enfant_Client = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        E1 = new javax.swing.JLabel();
        M1 = new javax.swing.JLabel();
        ME1 = new javax.swing.JLabel();
        D1 = new javax.swing.JLabel();
        EN1 = new javax.swing.JLabel();
        nai = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        enregistrer = new javax.swing.JLabel();
        enregistrer_ar = new javax.swing.JLabel();
        annuler_ar = new javax.swing.JLabel();
        annuler = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        jLabel13.setText("jLabel13");

        setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        setClosable(true);
        setForeground(java.awt.Color.lightGray);
        setIconifiable(true);
        setMaximizable(true);
        setMinimumSize(new java.awt.Dimension(894, 555));
        setPreferredSize(new java.awt.Dimension(894, 555));
        getContentPane().setLayout(null);

        jPanel1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel1.setLayout(null);

        C2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        C2.setText("CIN :");
        jPanel1.add(C2);
        C2.setBounds(10, 30, 60, 30);

        N2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        N2.setText("Nom :");
        jPanel1.add(N2);
        N2.setBounds(12, 121, 60, 30);

        P2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        P2.setText("Prenom :");
        jPanel1.add(P2);
        P2.setBounds(10, 210, 70, 30);

        T2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        T2.setText("N° Tele :");
        jPanel1.add(T2);
        T2.setBounds(10, 280, 60, 30);

        CIN_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        CIN_Client.setBorder(null);
        CIN_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        CIN_Client.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CIN_ClientActionPerformed(evt);
            }
        });
        jPanel1.add(CIN_Client);
        CIN_Client.setBounds(90, 30, 190, 30);

        Nom_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Nom_Client.setBorder(null);
        Nom_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        Nom_Client.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                Nom_ClientMouseClicked(evt);
            }
        });
        Nom_Client.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Nom_ClientActionPerformed(evt);
            }
        });
        jPanel1.add(Nom_Client);
        Nom_Client.setBounds(90, 120, 190, 30);

        Prenom_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Prenom_Client.setBorder(null);
        Prenom_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        Prenom_Client.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Prenom_ClientActionPerformed(evt);
            }
        });
        jPanel1.add(Prenom_Client);
        Prenom_Client.setBounds(90, 210, 190, 30);

        Numero_Tele_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Numero_Tele_Client.setBorder(null);
        Numero_Tele_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        jPanel1.add(Numero_Tele_Client);
        Numero_Tele_Client.setBounds(90, 280, 180, 30);

        jLabel12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel12);
        jLabel12.setBounds(80, 10, 230, 70);

        jLabel14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel14);
        jLabel14.setBounds(80, 110, 240, 50);

        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel15);
        jLabel15.setBounds(80, 200, 230, 50);

        jLabel16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel1.add(jLabel16);
        jLabel16.setBounds(80, 260, 230, 70);

        C1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        C1.setForeground(new java.awt.Color(0, 0, 0));
        C1.setText("الرقم الوطني :");
        jPanel1.add(C1);
        C1.setBounds(300, 30, 100, 30);

        N1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        N1.setForeground(new java.awt.Color(0, 0, 0));
        N1.setText("الاسم العائلي :");
        jPanel1.add(N1);
        N1.setBounds(310, 125, 100, 30);

        P1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        P1.setForeground(new java.awt.Color(0, 0, 0));
        P1.setText("الاسم الشخصي :");
        jPanel1.add(P1);
        P1.setBounds(300, 210, 110, 30);

        T1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        T1.setForeground(new java.awt.Color(0, 0, 0));
        T1.setText("رقم الهاتف :");
        jPanel1.add(T1);
        T1.setBounds(320, 280, 90, 30);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        jLabel3.setText("jLabel3");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(0, 0, 420, 400);

        getContentPane().add(jPanel1);
        jPanel1.setBounds(20, 20, 420, 390);

        jPanel2.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
        jPanel2.setLayout(null);

        E2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        E2.setText("Email :");
        jPanel2.add(E2);
        E2.setBounds(10, 20, 60, 40);

        M2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        M2.setText("Marier :");
        jPanel2.add(M2);
        M2.setBounds(10, 80, 70, 40);

        ME2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        ME2.setText("Métier :");
        jPanel2.add(ME2);
        ME2.setBounds(10, 160, 80, 30);

        D2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        D2.setText("Date de");
        jPanel2.add(D2);
        D2.setBounds(20, 250, 60, 20);

        EN2.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        EN2.setText("N° Enfants :");
        jPanel2.add(EN2);
        EN2.setBounds(10, 320, 90, 30);

        Date_Naissance_Client.setBackground(new java.awt.Color(255, 255, 255));
        Date_Naissance_Client.setDateFormatString("YYYY-MM-dd");
        jPanel2.add(Date_Naissance_Client);
        Date_Naissance_Client.setBounds(110, 250, 190, 30);

        Email_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Email_Client.setBorder(null);
        Email_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        jPanel2.add(Email_Client);
        Email_Client.setBounds(110, 30, 190, 30);

        oui.setBackground(new java.awt.Color(204, 204, 204));
        buttonGroup1.add(oui);
        oui.setText("oui");
        oui.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ouiMouseClicked(evt);
            }
        });
        jPanel2.add(oui);
        oui.setBounds(130, 90, 70, 30);

        non.setBackground(new java.awt.Color(227, 187, 173));
        buttonGroup1.add(non);
        non.setText("non");
        non.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                nonMouseClicked(evt);
            }
        });
        jPanel2.add(non);
        non.setBounds(240, 90, 70, 30);

        Metier_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Metier_Client.setBorder(null);
        Metier_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        jPanel2.add(Metier_Client);
        Metier_Client.setBounds(110, 160, 190, 30);

        Nombre_Enfant_Client.setFont(new java.awt.Font("DejaVu Sans Condensed", 1, 14)); // NOI18N
        Nombre_Enfant_Client.setBorder(null);
        Nombre_Enfant_Client.setMargin(new java.awt.Insets(1, 0, 0, 0));
        jPanel2.add(Nombre_Enfant_Client);
        Nombre_Enfant_Client.setBounds(110, 320, 190, 30);

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel2.add(jLabel17);
        jLabel17.setBounds(100, 10, 250, 70);

        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel2.add(jLabel18);
        jLabel18.setBounds(100, 140, 230, 70);

        jLabel19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel2.add(jLabel19);
        jLabel19.setBounds(100, 240, 230, 50);

        jLabel20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Labels/txt1.png"))); // NOI18N
        jPanel2.add(jLabel20);
        jLabel20.setBounds(100, 300, 230, 70);

        E1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        E1.setForeground(new java.awt.Color(0, 0, 0));
        E1.setText("البريد الالكتروني :");
        jPanel2.add(E1);
        E1.setBounds(309, 25, 110, 40);

        M1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        M1.setForeground(new java.awt.Color(0, 0, 0));
        M1.setText("الحالة العائلية :");
        jPanel2.add(M1);
        M1.setBounds(320, 90, 110, 30);

        ME1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        ME1.setForeground(new java.awt.Color(0, 0, 0));
        ME1.setText("المهنة :");
        jPanel2.add(ME1);
        ME1.setBounds(340, 160, 70, 30);

        D1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        D1.setForeground(new java.awt.Color(0, 0, 0));
        D1.setText("تاريخ الازدياد : ");
        jPanel2.add(D1);
        D1.setBounds(310, 250, 110, 40);

        EN1.setFont(new java.awt.Font("Amiri", 1, 14)); // NOI18N
        EN1.setForeground(new java.awt.Color(0, 0, 0));
        EN1.setText("عدد الاطفال :");
        jPanel2.add(EN1);
        EN1.setBounds(320, 320, 100, 30);

        nai.setFont(new java.awt.Font("Serif", 1, 12)); // NOI18N
        nai.setText("Naissance");
        jPanel2.add(nai);
        nai.setBounds(10, 270, 90, 20);

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        jPanel2.add(jLabel4);
        jLabel4.setBounds(0, 0, 420, 430);

        getContentPane().add(jPanel2);
        jPanel2.setBounds(450, 20, 420, 420);

        enregistrer.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/Enregistrer_Client.png"))); // NOI18N
        enregistrer.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                enregistrerMouseReleased(evt);
            }
        });
        getContentPane().add(enregistrer);
        enregistrer.setBounds(640, 450, 150, 50);

        enregistrer_ar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/save_ar.png"))); // NOI18N
        enregistrer_ar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                enregistrer_arMouseReleased(evt);
            }
        });
        getContentPane().add(enregistrer_ar);
        enregistrer_ar.setBounds(190, 460, 170, 40);

        annuler_ar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/annuler.png"))); // NOI18N
        annuler_ar.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                annuler_arMouseReleased(evt);
            }
        });
        getContentPane().add(annuler_ar);
        annuler_ar.setBounds(10, 460, 170, 40);

        annuler.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Buttons/Annuler.png"))); // NOI18N
        annuler.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                annulerMouseReleased(evt);
            }
        });
        getContentPane().add(annuler);
        annuler.setBounds(460, 450, 150, 50);

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Main/Images/Accueil/wallhaven-19788.jpg"))); // NOI18N
        getContentPane().add(jLabel2);
        jLabel2.setBounds(0, 0, 1050, 560);

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    public void Traduire()
    {
        C2.setVisible(false);
        N2.setVisible(false);
        P2.setVisible(false);
        T2.setVisible(false);
        E2.setVisible(false);
        M2.setVisible(false);
        ME2.setVisible(false);
        D2.setVisible(false);
        EN2.setVisible(false);
        nai.setVisible(false);
        enregistrer.setVisible(false);
        annuler.setVisible(false);
        
        
        C1.setVisible(true);
        N1.setVisible(true);
        P1.setVisible(true);
        T1.setVisible(true);
        E1.setVisible(true);
        M1.setVisible(true);
        ME1.setVisible(true);
        D1.setVisible(true);
        EN1.setVisible(true);
        oui.setText("نعم");
        non.setText("لا");
        enregistrer_ar.setVisible(true);
        annuler_ar.setVisible(true);
        
        
        
    }
    
    
    
    public void Visibility()
    {
        
        C1.setVisible(false);
        N1.setVisible(false);
        P1.setVisible(false);
        T1.setVisible(false);
        E1.setVisible(false);
        M1.setVisible(false);
        ME1.setVisible(false);
        D1.setVisible(false);
        EN1.setVisible(false);
        enregistrer_ar.setVisible(false);
        annuler_ar.setVisible(false);
    }
    
    public String  Status_Client()
        {
            String marier ="";
                if(oui.isSelected())
                {
                    return  "Marié";
                }
                else if(non.isSelected()) {
                    
                    
                    return "non marié";
                    
                }
                else{
                
                    JOptionPane.showMessageDialog(null, "Error");
                }
        return null;
                
                
        }
        
    public int Nombre_Enfant()
        {
        
            if(oui.isSelected())
            {
                return Integer.parseInt(Nombre_Enfant_Client.getText());
            }
            else if(non.isSelected())
            {
                return 0;
            }
        return 0;
        }
        
    
    
    
    private void Metier_ClientActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    }                                             
    
    public void Enregistrer_Client()
    {
            try{
                         
                        String sql1 ="insert into client(CIN_CLIENT,NOM,PRENOM,NUMERO_TELE,EMAIL,SITUATION,DATE_NAISSANCE,METIER,NOMBRE_ENFANTS) values(?,?,?,?,?,?,?,?,?)";
                        //String sql0="insert into CHAMBRE(CIN_CLIENT,ETAGE_CHAMBRE,TYPE_CHAMBRE,STATUS_CHAMBRE) values(?,?,?,?)";
                        //String sql2="insert into RESERVATION(CIN_CLIENT) values(?)";
                        String sql3="update dernier_client set CIN_CLIENT=? where ID_DERNIER=1"; 
                   
                        // inserer au table CLIENT
                        PreparedStatement ps1 = conn.prepareStatement(sql1); 
                        ps1.setString(1, CIN_Client.getText());
                        ps1.setString(2, Nom_Client.getText());
                        ps1.setString(3, Prenom_Client.getText());
                        ps1.setString(4, Numero_Tele_Client.getText());
                        ps1.setString(5, Email_Client.getText());
                        ps1.setString(6, Status_Client());
                        ps1.setString(7, ((JTextField)Date_Naissance_Client.getDateEditor().getUiComponent()).getText());
                        ps1.setString(8, Metier_Client.getText());
                        ps1.setInt(9, Nombre_Enfant());
                        
                       /* PreparedStatement ps0 = conn.prepareStatement(sql0);
                        ps0.setString(1, CIN_Client.getText());
                        ps0.setInt(2, 0);
                        ps0.setInt(3, 0);
                        ps0.setString(4, "non");*/
                        
                        // Insertion dans la table CHAMBRE
                        /*PreparedStatement ps2 = conn.prepareStatement(sql2); 
                        ps2.setString(1, CIN_Client.getText());*/
                        
                        
                        //Insertion dans la table PAIEMENT
                        PreparedStatement ps3 = conn.prepareStatement(sql3); 
                        ps3.setString(1, CIN_Client.getText());
                        
                        
                        //execution des requetes
                        ps1.executeUpdate();
                        //ps0.executeUpdate();
                        ps3.executeUpdate();
                        //ps4.executeUpdate(sql4);
                        
                        JOptionPane.showMessageDialog(null,"Les information a enregistrer avec succes");
                        
                        
                }catch(SQLException | HeadlessException e)
                {
                    
               JOptionPane.showMessageDialog(null,"Echec d'Insertion Client "+""+e.getMessage());  
                    
                }
                
                
    
    }
                              
    
    
    
    
    private void CIN_ClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CIN_ClientActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CIN_ClientActionPerformed

    private void Prenom_ClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Prenom_ClientActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Prenom_ClientActionPerformed
    private void Verifier_accompilssement()
    {
    
        if(CIN_Client.equals("") ){}
        if(Nom_Client.equals("")){} 
        if(Prenom_Client.equals("")){}
        if(Numero_Tele_Client.equals("")){}
        if(Email_Client.equals("")){}
        if(Date_Naissance_Client.equals("")){}
        if(Metier_Client.equals("")){}
    
    }
    private void enregistrerMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_enregistrerMouseReleased
        
        
        if(CIN_Client.equals("") && Nom_Client.equals("") && Prenom_Client.equals("") && Numero_Tele_Client.equals("") && Email_Client.equals("") && Date_Naissance_Client.equals("") && Metier_Client.equals("")){
         JOptionPane.showMessageDialog(null, "Remplire les champs vide s'il-vous plais!");
        }
        else{
        
            
            Enregistrer_Client();
        }
    }//GEN-LAST:event_enregistrerMouseReleased
    private void Annuler(){
        CIN_Client.setText("");
        Nom_Client.setText("");
        Prenom_Client.setText("");
        Numero_Tele_Client.setText("");
        Email_Client.setText("");
        Date_Naissance_Client.setDate(null);
        Metier_Client.setText("");
    }
    private void annulerMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_annulerMouseReleased
        
        Annuler();
        
        
    }//GEN-LAST:event_annulerMouseReleased

    private void nonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_nonMouseClicked
       Nombre_Enfant_Client.setEditable(false);
       Nombre_Enfant_Client.setBackground(Color.PINK);
    }//GEN-LAST:event_nonMouseClicked

    private void ouiMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ouiMouseClicked
       Nombre_Enfant_Client.setEditable(true);
       Nombre_Enfant_Client.setBackground(Color.white);
    }//GEN-LAST:event_ouiMouseClicked
    
    
    private void assurer()
    {
    
        try {
            String cin=CIN_Client.getText();
            String sql_user="select * from client where CIN_CLIENT='"+cin+"'";
            
            PreparedStatement ps=conn.prepareStatement(sql_user);
            rs=ps.executeQuery();
            if(rs.next())
                {
                    JOptionPane.showMessageDialog(null, "ce client a déja reservé une chambre!");
                    enregistrer.disable();
                
                }
            else{
                enregistrer.enable();
            }
            
        } catch (Exception e) {
        }
    }
    
    
    private void Nom_ClientMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_Nom_ClientMouseClicked
        assurer();
    }//GEN-LAST:event_Nom_ClientMouseClicked

    private void Nom_ClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Nom_ClientActionPerformed
        assurer();
    }//GEN-LAST:event_Nom_ClientActionPerformed

    private void enregistrer_arMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_enregistrer_arMouseReleased
        Enregistrer_Client();
    }//GEN-LAST:event_enregistrer_arMouseReleased

    private void annuler_arMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_annuler_arMouseReleased
       Annuler();
    }//GEN-LAST:event_annuler_arMouseReleased


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel C1;
    private javax.swing.JLabel C2;
    private javax.swing.JTextField CIN_Client;
    private javax.swing.JLabel D1;
    private javax.swing.JLabel D2;
    private com.toedter.calendar.JDateChooser Date_Naissance_Client;
    private javax.swing.JLabel E1;
    private javax.swing.JLabel E2;
    private javax.swing.JLabel EN1;
    private javax.swing.JLabel EN2;
    private javax.swing.JTextField Email_Client;
    private javax.swing.JLabel M1;
    private javax.swing.JLabel M2;
    private javax.swing.JLabel ME1;
    private javax.swing.JLabel ME2;
    private javax.swing.JTextField Metier_Client;
    private javax.swing.JLabel N1;
    private javax.swing.JLabel N2;
    private javax.swing.JTextField Nom_Client;
    private javax.swing.JTextField Nombre_Enfant_Client;
    private javax.swing.JTextField Numero_Tele_Client;
    private javax.swing.JLabel P1;
    private javax.swing.JLabel P2;
    private javax.swing.JTextField Prenom_Client;
    private javax.swing.JLabel T1;
    private javax.swing.JLabel T2;
    private javax.swing.JLabel annuler;
    private javax.swing.JLabel annuler_ar;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private javax.swing.JLabel enregistrer;
    private javax.swing.JLabel enregistrer_ar;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel nai;
    private javax.swing.JRadioButton non;
    private javax.swing.JRadioButton oui;
    // End of variables declaration//GEN-END:variables
}
